<template>
  <div class="_wz_expenditurePlanDetails">

      <table cellpadding="0" cellspacing="0" border="0">
        <tbody>
        <tr>
          <td style="font-size: 18px;font-weight: 600;display: flex;justify-content: center;align-items: center;" colspan="5">{{ formData.outlayDrawPlanName }}</td>
        </tr>
        </tbody>
      </table>
      <table cellpadding="0" cellspacing="0" border="0">
        <colgroup>
          <col width="14%" />
          <col width="20%" />
          <col width="13%" />
          <col width="20%" />
          <col width="13%" />
          <col width="20%" />
        </colgroup>
        <tbody>
        <tr>
          <td style="font-weight: 600;border-top: 0px;">经营企业</td>
          <td colspan="2" style="border-top: 0px;">
            {{ formData.deptName ? formData.deptName : "--" }}
          </td>
          <td style="font-weight: 600;border-top: 0px;">经营类型</td>
          <td colspan="2" style="border-top: 0px;">
            {{ formData.deptTransportName ? formData.deptTransportName : "--" }}
          </td>
        </tr>
        <tr>
          <td style="font-weight: 600;border-top: 0px;">去年营收</td>
          <td colspan="1" style="border-top: 0px;">
            {{formData.outlayDrawPlanIncome ? formData.outlayDrawPlanIncome + ' 元' : "--" }}
          </td>
          <td style="font-weight: 600;border-top: 0px;">提取标准</td>
          <td colspan="1" style="border-top: 0px;">
            {{formData.outlayDrawPlanStandard ? formData.outlayDrawPlanStandard + "%" : "--" }}
          </td>
          <td style="font-weight: 600;border-top: 0px;">计划金额</td>
          <td colspan="1" style="border-top: 0px;">
            {{formData.outlayDrawPlanAmount ? formData.outlayDrawPlanAmount + '元' : "--" }}
          </td>
        </tr>
        <tr>
          <td style="font-weight: 600;border-top: 0px;">登记日期</td>
          <td colspan="1" style="border-top: 0px;">
            {{formData.outlayDrawPlanDate ? formData.outlayDrawPlanDate : "--" }}
          </td>
          <td style="font-weight: 600;border-top: 0px;">登记人</td>
          <td colspan="1" style="border-top: 0px;">
            {{formData.outlayDrawPlanRegistrantName ? formData.outlayDrawPlanRegistrantName: "--" }}
          </td>
          <td style="font-weight: 600;border-top: 0px;">提取金额</td>
          <td colspan="1" style="border-top: 0px;">
            {{formData.outlayDrawPlanAmountUse ? formData.outlayDrawPlanAmountUse: "--" }}
          </td>
        </tr>
        <tr>
          <td colspan="6" style="font-weight: 600;border-top: 0px;position: relative;">
            按安全生产工作计划实际需要测算


            <div style="font-weight: 600;position: absolute;right: 50px;top: 10px;">
              单位：元
            </div>
          </td>

        </tr>
        </tbody>
      </table>
      <table cellpadding="0" cellspacing="0" border="0">
        <colgroup>
          <col width="3%" />
          <col width="10%" />
          <col width="4%" />
          <col width="4%" />
          <col width="4%" />
          <col width="4%" />
          <col width="4%" />
          <col width="4%" />
          <col width="4%" />
          <col width="4%" />
          <col width="4%" />
          <col width="4%" />
          <col width="4%" />
          <col width="4%" />
          <col width="4%" />
          <col width="4%" />
          <col width="4%" />
          <col width="4%" />
          <col width="4%" />
          <col width="4%" />
          <col width="4%" />
          <col width="4%" />
          <col width="4%" />
          <col width="4%" />
          <col width="4%" />
          <col width="4%" />
          <col width="4%" />
          <col width="4%" />
        </colgroup>
        <tr>
          <td rowspan="2" style="text-align: right;font-weight: 600;border-top: 0px;">序号</td>
          <td rowspan="2" style="font-weight: 600;border-top: 0px;">安全费用名目</td>
          <td colspan="2" style="text-align: center;font-weight: 600;border-top: 0px">一月份</td>
          <td colspan="2" style="text-align: center;font-weight: 600;border-top: 0px">二月份</td>
          <td colspan="2" style="text-align: center;font-weight: 600;border-top: 0px">三月份</td>
          <td colspan="2" style="text-align: center;font-weight: 600;border-top: 0px">四月份</td>
          <td colspan="2" style="text-align: center;font-weight: 600;border-top: 0px">五月份</td>
          <td colspan="2" style="text-align: center;font-weight: 600;border-top: 0px">六月份</td>
          <td colspan="2" style="text-align: center;font-weight: 600;border-top: 0px">七月份</td>
          <td colspan="2" style="text-align: center;font-weight: 600;border-top: 0px">八月份</td>
          <td colspan="2" style="text-align: center;font-weight: 600;border-top: 0px">九月份</td>
          <td colspan="2" style="text-align: center;font-weight: 600;border-top: 0px">十月份</td>
          <td colspan="2" style="text-align: center;font-weight: 600;border-top: 0px">十一月份</td>
          <td colspan="2" style="text-align: center;font-weight: 600;border-top: 0px">十二月份</td>
          <td colspan="2" style="text-align: center;font-weight: 600;border-top: 0px">合计</td>
        </tr>
        <tr>
          <template v-for="(item, index) in 13">
            <td colspan="1" style="border-top: 0px;">计划</td>
            <td colspan="1" style="border-top: 0px;">提取</td>
          </template>
        </tr>
        <template v-for="(item, index) in tableDataDataList">
          <tr>
            <td style="border-top: 0px;">{{ index + 1 }}</td>
            <td style="border-top: 0px;">{{ item.outlayDrawPlanItemName }}</td>
            <td style="border-top: 0px;">
              {{item.outlayDrawPlanItemAmountJan ? item.outlayDrawPlanItemAmountJan : "" }}
            </td>
            <td style="border-top: 0px;">
              {{item.outlayDrawPlanItemAmountJanUse ? item.outlayDrawPlanItemAmountJanUse : "" }}
            </td>

            <td style="border-top: 0px;">
              {{item.outlayDrawPlanItemAmountFeb ? item.outlayDrawPlanItemAmountFeb : "" }}
            </td>
            <td style="border-top: 0px;">
              {{item.outlayDrawPlanItemAmountFebUse ? item.outlayDrawPlanItemAmountFebUse : "" }}
            </td>

            <td style="border-top: 0px;">
              {{item.outlayDrawPlanItemAmountMar ? item.outlayDrawPlanItemAmountMar : "" }}
            </td>
            <td style="border-top: 0px;">
              {{item.outlayDrawPlanItemAmountMarUse ? item.outlayDrawPlanItemAmountMarUse : "" }}
            </td>

            <td style="border-top: 0px;">
              {{item.outlayDrawPlanItemAmountApr ? item.outlayDrawPlanItemAmountApr : "" }}
            </td>
            <td style="border-top: 0px;">
              {{item.outlayDrawPlanItemAmountAprUse ? item.outlayDrawPlanItemAmountAprUse : "" }}
            </td>

            <td style="border-top: 0px;">
              {{item.outlayDrawPlanItemAmountMay ? item.outlayDrawPlanItemAmountMay : "" }}
            </td>
            <td style="border-top: 0px;">
              {{item.outlayDrawPlanItemAmountMayUse ? item.outlayDrawPlanItemAmountMayUse : "" }}
            </td>

            <td style="border-top: 0px;">
              {{item.outlayDrawPlanItemAmountJun ? item.outlayDrawPlanItemAmountJun : "" }}
            </td>
            <td style="border-top: 0px;">
              {{item.outlayDrawPlanItemAmountJunUse ? item.outlayDrawPlanItemAmountJunUse : "" }}
            </td>

            <td style="border-top: 0px;">
              {{item.outlayDrawPlanItemAmountJul ? item.outlayDrawPlanItemAmountJul : "" }}
            </td>
            <td style="border-top: 0px;">
              {{item.outlayDrawPlanItemAmountJulUse ? item.outlayDrawPlanItemAmountJulUse : "" }}
            </td>

            <td style="border-top: 0px;">
              {{item.outlayDrawPlanItemAmountAug ? item.outlayDrawPlanItemAmountAug : "" }}
            </td>
            <td style="border-top: 0px;">
              {{item.outlayDrawPlanItemAmountAugUse ? item.outlayDrawPlanItemAmountAugUse : "" }}
            </td>

            <td style="border-top: 0px;">
              {{item.outlayDrawPlanItemAmountSep ? item.outlayDrawPlanItemAmountSep : "" }}
            </td>
            <td style="border-top: 0px;">
              {{item.outlayDrawPlanItemAmountSepUse ? item.outlayDrawPlanItemAmountSepUse : "" }}
            </td>

            <td style="border-top: 0px;">
              {{item.outlayDrawPlanItemAmountOct ? item.outlayDrawPlanItemAmountOct : "" }}
            </td>
            <td style="border-top: 0px;">
              {{item.outlayDrawPlanItemAmountOctUse ? item.outlayDrawPlanItemAmountOctUse : "" }}
            </td>

            <td style="border-top: 0px;">
              {{item.outlayDrawPlanItemAmountNov ? item.outlayDrawPlanItemAmountNov : "" }}
            </td>
            <td style="border-top: 0px;">
              {{item.outlayDrawPlanItemAmountNovUse ? item.outlayDrawPlanItemAmountNovUse : "" }}
            </td>
            <td style="border-top: 0px;">
              {{item.outlayDrawPlanItemAmountDec ? item.outlayDrawPlanItemAmountDec : "" }}
            </td>
            <td style="border-top: 0px;">
              {{item.outlayDrawPlanItemAmountDecUse ? item.outlayDrawPlanItemAmountDecUse : "" }}
            </td>
            <td style="border-top: 0px;">
              {{item.outlayDrawPlanItemAmountTotal ? item.outlayDrawPlanItemAmountTotal : "" }}
            </td>
            <td style="border-top: 0px;">
              {{item.outlayDrawPlanItemAmountTotalUse ? item.outlayDrawPlanItemAmountTotalUse : "" }}
            </td>
          </tr>
        </template>
        <tr>
          <td colspan="2" style="text-align: center;font-weight: 600;border-top: 0px;">计划合计</td>
          <td colspan="12" style="font-weight: 600;border-top: 0px;">{{ totalPlanned + "元" }}</td>
          <td colspan="2" style="text-align: center;font-weight: 600;border-top: 0px;">提取合计</td>
          <td colspan="12" style="font-weight: 600;border-top: 0px;">{{ totalWithdrawal + "元" }}</td>
        </tr>
      </table>


  </div>
</template>
<script>


import {
  getCurrentInstance,
  inject,
  nextTick,
  reactive,
  toRefs,
  toRef,
  onBeforeMount,
  onMounted,
  onBeforeUpdate,
  onUpdated,
  onBeforeUnmount,
  onUnmounted,
  ref,
  defineComponent,
  toRaw,
  watch,
  resolveComponent
} from 'vue'
import { useRouter,useRoute } from "vue-router";

import { useMainStore } from '../../../store'  //pinia 使用 类似 vuex
import { storeToRefs } from 'pinia'//pinia 使用 类似 vuex
const mainStore = useMainStore() //pinia 使用 类似 vuex

//reactive
export default defineComponent({
  name: 'expenditurePlanDetails',//组件名称
  components: {
  },//组件引用
  props: ['selectData'],//接收来自父组件的数据
  setup (props,context) {


    const apiUrl = inject('$apiUrl'); // 变量全局化 后台地址
    const $axios = inject('$axiosInterceptor');// 变量全局化 axios
    const $ViewUIPlus = inject('$ViewUIPlus');//引用全局组件
    const router = useRouter();//路由跳转使用


    const state = reactive({
      formData: {},//培训数据
      totalPlanned:0,//计划合计
      totalWithdrawal:0,//提取合计
      tableDataDataList:[],



    });


    //加载数据
    const loadData = ()=>{
      $axios.post(apiUrl.safetyOutlayOutlayDrawPlanInfo,{uuid:props.selectData.uuid}).then((res) => {
        if (!!res) {
          state.formData = res.data.data;
          state.tableDataDataList = res.data.data.outlayDrawPlanItemList;





          res.data.data.outlayDrawPlanItemList.forEach(
              item => {
                let outlayDrawPlanItemAmountTotalUse =
                    item.outlayDrawPlanItemAmountJanUse ?  item.outlayDrawPlanItemAmountJanUse : 0 +
                    item.outlayDrawPlanItemAmountFebUse ?  item.outlayDrawPlanItemAmountFebUse : 0 +
                    item.outlayDrawPlanItemAmountMarUse ?  item.outlayDrawPlanItemAmountMarUse : 0 +
                    item.outlayDrawPlanItemAmountAprUse ?  item.outlayDrawPlanItemAmountAprUse : 0 +
                    item.outlayDrawPlanItemAmountMayUse ?  item.outlayDrawPlanItemAmountMayUse : 0 +
                    item.outlayDrawPlanItemAmountJunUse ?  item.outlayDrawPlanItemAmountJunUse : 0 +
                    item.outlayDrawPlanItemAmountJulUse ?  item.outlayDrawPlanItemAmountJulUse : 0 +
                    item.outlayDrawPlanItemAmountAugUse ?  item.outlayDrawPlanItemAmountAugUse : 0 +
                    item.outlayDrawPlanItemAmountSepUse ?  item.outlayDrawPlanItemAmountSepUse : 0 +
                    item.outlayDrawPlanItemAmountOctUse ?  item.outlayDrawPlanItemAmountOctUse : 0 +
                    item.outlayDrawPlanItemAmountNovUse ?  item.outlayDrawPlanItemAmountNovUse : 0 +
                    item.outlayDrawPlanItemAmountDecUse ?  item.outlayDrawPlanItemAmountDecUse : 0

                state.totalPlanned += item.outlayDrawPlanItemAmountTotal ? item.outlayDrawPlanItemAmountTotal : 0
                state.totalWithdrawal += outlayDrawPlanItemAmountTotalUse ? outlayDrawPlanItemAmountTotalUse : 0
              }
          )

        }
      }).catch((err) => {
        console.log("失败", err)
      })


    }


    // 其他的生命周期
    onBeforeMount (() => {//beforeMount挂载前状态 // console.log("App ===> 相当于 vue2.x 中 beforeMount")

    })
    onMounted (() => {//mounted 挂载结束状态  // console.log("App ===> 相当于 vue2.x 中 mounted")
      loadData()
    })

    // 注意，onBeforeUpdate 和 onUpdated 里面不要修改值
    onBeforeUpdate (() => {//beforeUpdate 更新前状态 // console.log("App ===> 相当于 vue2.x 中 beforeUpdate")

    })

    onUpdated (() => {//updated 更新完成状态 // console.log("App ===> 相当于 vue2.x 中 updated")

    })

    onBeforeUnmount (() => {//beforeDestroy 销毁前状态  // console.log("App ===> 相当于 vue2.x 中 beforeDestroy")
    })

    onUnmounted (() => {//destroyed 销毁完成状态  // console.log("App ===> 相当于 vue2.x 中 destroyed")
    })

    return {
      ...toRefs(state),
      apiUrl,
    }
  }
})


</script>
<style lang="less">

._wz_expenditurePlanDetails {
  padding: 10px;
  height: 100%;
  overflow: auto;

  table {
    table-layout: fixed;
    width: 100%;
    border-collapse: collapse;
    border-spacing: 0;
    font-size: 12px !important;

    td {
      min-width: 0;
      height: 40px;
      box-sizing: border-box;
      text-align: left;
      text-overflow: ellipsis;
      border: 1px solid #515a6e;
      padding: 0 10px;
      word-break: break-word;
    }
  }
}
</style>
